package com.myk.game.gobangchess;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Mode {

    private final Set<String> modeSet;
    private String curMode;

    public Mode(String... modes) {
        curMode = "默认";
        modeSet = new HashSet<>();
        modeSet.add(curMode);
        if (modes != null) {
            modeSet.addAll(Arrays.asList(modes));
        }
    }

    public boolean isCurMode(String mode) {
        if (modeSet.contains(mode)) {
            return curMode.equals(mode);
        }
        return false;
    }

    public void setCurMode(String mode) {
        if (modeSet.contains(mode)) {
            this.curMode = mode;
        }
        else {
            this.curMode = "默认";
        }
    }

    public String[] getAllModes() {
        return modeSet.toArray(new String[0]);
    }

    public String getCurMode() {
        if (modeSet.contains(curMode)) {
            return curMode;
        }
        else {
            curMode = "默认";
            return curMode;
        }
    }

    public static boolean isCurMode(Room room, String mode){
        return room.isCurMode(mode);
    }
}
